home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / qbsnip.zip / PRINTF.BAS < prev    next >
BASIC Source File  |  1997-05-04  |  1KB  |  69 lines

  1. ' PRINTF.BAS
  2. ' by Ronnie Weiss
  3. '
  4. ' public domain
  5. ' No warranties or guarantees are expressed or implied.
  6. '
  7. 'Does color, locate and printing in one command. Switches can be put
  8. 'anywhere in the parameter (string). You must leave a space in between
  9. 'all switches.
  10. '
  11. 'Switches are as follows:
  12. '
  13. '/n - skips to the beginning of the next line
  14. '// - prints a /
  15. '/f - followed by the forground color, changes text color
  16. '/b - followed by the background color, changes background color
  17. '/r - followed by the y coordinate changes the y cursor position
  18. '/c - followed by the x coordinate changes the x cursor position
  19.  
  20. DECLARE SUB printf (txt$)
  21.  
  22. printf "/f12 /r3 /c23 Hello"
  23.  
  24. SUB printf (txt$)
  25. x% = 1
  26. DO
  27. attr% = CINT(VAL(MID$(txt$, x% + 2, 2))) 'convert numbers in
  28. SELECT CASE LCASE$(MID$(txt$, x%, 2))    'the text to integers
  29.     CASE "/f"
  30.     COLOR attr%
  31.     IF attr% > 9 THEN
  32.         x% = x% + 4
  33.     ELSE
  34.         x% = x% + 3
  35.     END IF
  36.     CASE "/b"
  37.     COLOR , attr%
  38.     IF attr% > 9 THEN
  39.         x% = x% + 4
  40.     ELSE
  41.         x% = x% + 3
  42.     END IF
  43.     CASE "/n"
  44.     PRINT
  45.         x% = x% + 2
  46.     CASE "/r"
  47.     LOCATE attr%
  48.     IF attr% > 9 THEN
  49.         x% = x% + 4
  50.     ELSE
  51.         x% = x% + 3
  52.     END IF
  53.     CASE "/c"
  54.     LOCATE , attr%
  55.     IF attr% > 9 THEN
  56.         x% = x% + 4
  57.     ELSE
  58.         x% = x% + 3
  59.     END IF
  60.     CASE "//"
  61.     PRINT "/";
  62.     x% = x% + 2
  63. END SELECT
  64. PRINT MID$(txt$, x%, 1); 'Print the text
  65. x% = x% + 1
  66. LOOP UNTIL LEN(txt$) < x%
  67. END SUB
  68.  
  69.